plat = smart

CFLAGS += -O2 -Wall

ifeq ($(plat), pc)
  CXX = g++
  LIB = -L ../lib -lunp -lpthread
endif

ifeq ($(plat), smart)
  CXX = arm-vfp-linux-gnu-g++
  LIB = -L ../lib -larm-vfp-linux-gnu-unp -lpthread
endif

ifeq ($(plat), mini)
  CXX = arm-linux-g++
  LIB = -L ../lib -larm-linux-unp -lpthread
endif

PROG_NAME = gateWay node test
INCLUDE = -I ../lib

all : ${PROG_NAME}

gateWay : dataDevice.o gateWay.o readConfig.o signal.o netDevice.o thread.o network.o CCycleBuffer.o
	${CXX} -o gateWay $^ ${LIB}

node : node.o dataDevice.o readConfig.o signal.o netDevice.o thread.o network.o CCycleBuffer.o
	${CXX} -o node $^ ${LIB}

test : test.o netDevice.o dataDevice.o thread.o	CCycleBuffer.o signal.o
	${CXX} -o test $^ ${LIB}

readConfig.o : readConfig.h readConfig.cpp
dataDevice.o : dataDevice.cpp dataDevice.h
	${CXX} ${CFLAGS} -c $< ${INCLUDE}
signal.o : signal.h signal.cpp
gateWay.o : gateWay.cpp signal.h readConfig.h netDevice.h
	${CXX} ${CFLAGS} -c $< ${INCLUDE}
node.o : node.cpp dataDevice.h readConfig.h netDevice.h config.h
	${CXX} ${CFLAGS} -c $< ${INCLUDE}
test.o : test.cpp dataDevice.h netDevice.h
	${CXX} ${CFLAGS} -c $< ${INCLUDE}
netDevice.o : netDevice.cpp netDevice.h dataDevice.h CCycleBuffer.h signal.h
	${CXX} ${CFLAGS} -c $< ${INCLUDE}
thread.o : thread.cpp thread.h
	${CXX} ${CFLAGS} -c $< ${INCLUDE}
network.o : network.cpp network.h
	${CXX} ${CFLAGS} -c $< ${INCLUDE}
CCycleBuffer.o : CCycleBuffer.cpp CCycleBuffer.h
	${CXX} ${CFLAGS} -c $< ${INCLUDE}

.PHONY : clean
clean:
	-rm *.o ${PROG_NAME}
